package com.cg.controller;

import com.cg.dto.HealthInfoPageDto;
import com.cg.dto.Result;
import com.cg.dto.ResultUtils;
import com.cg.service.HealthInfoService;
import com.cg.vo.HealthInfoVo;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (HealthInfo)表控制层
 *
 * @author chengong
 * @since 2024-01-14 15:38:18
 */
@RestController
@RequestMapping("/healthInfo")
public class HealthInfoController {
    /**
     * 服务对象
     */
    @Resource
    private HealthInfoService healthInfoService;

    /**
     * 健康资讯信息展示
     */
    @PostMapping("/queryHealthList")
    public Result<List<HealthInfoVo>> queryHealthList() {
        List<HealthInfoVo> healthInfoVos = healthInfoService.queryHealthList();
        return ResultUtils.returnDataSuccess(healthInfoVos);
    }


    /**
     * 根据标题模糊查询资讯
     */
    @PostMapping("/queryHealthListByTitle")
    public Result<Map<String,Object>> queryHealthListByTitle(@RequestBody HealthInfoPageDto healthInfoPageDto){
        Map<String,Object> map = new HashMap<>();
        PageInfo<HealthInfoVo> pageInfo = healthInfoService.queryHealthListByTitle(healthInfoPageDto);
        map.put("pageInfo",pageInfo);
        return ResultUtils.returnDataSuccess(map);
    }

}

